{% extends "tcms_base.html" %}
{% load static %}
{% load report_tags %}

{% block subtitle %}Custom Report Detail{% endblock %}

{% block custom_stylesheet %}
<link rel="stylesheet" type="text/css" href="{% static 'style/print.css' %}" media="print" />
{% endblock %}

{% block custom_javascript %}
<script type="text/javascript" src="{% static 'js/report.js' %}"></script>
<script type="text/javascript">
Nitrate.Utils.after_page_load(Nitrate.Report.CustomDetails.on_load);
</script>
{% endblock %}

{% block contents %}
<div id="content">
	<div class="report_title_bg">
		<form action="{% url "report-custom-details" %}">
			{{ form.product.label }}: {{ form.product }}<br />
			{{ form.pk__in.label }}: {{ form.pk__in }}<br />
			<input type="submit" value="Submit" />
		</form>
		{% if report_errors %}
		<div>{{ report_errors }}</div>
		{% endif %}
	</div>

	{% if not report_errors %}
	<table cellpadding="0" cellspacing="0" class="table_noborder" border="0">
		{% for build in builds %}
		<tr>
			<td>
				<strong>{{ build.build__name }}</strong>
				Plan<span class="red">{{ build.plans_count|default_if_none:0 }}</span>
				Run<span class="red">{{ build.runs_count|default_if_none:0 }}</span>
				Manual Cases<span class="red">{{manual_count|percentage:total_count}} ({{manual_count}}/{{total_count}})</span>
				Automated Cases<span class="red">{{auto_count|percentage:total_count}} ({{auto_count}}/{{total_count}})</span>
				Manual/Automated<span class="red">{{both_count|percentage:total_count}} ({{both_count}}/{{total_count}})</span>
			</td>
			<td width="110">Passed Case-Run</td>
			<td width="100">
				<div class="progress-bar">
					<div class="progress-inner" style="width:auto;margin-right:-50px;text-align:center">
						<div class="progress-passed" style="width:{{ build.passed_case_runs_percent|floatformat:1 }}px;">&nbsp;</div>
					</div>
					<div class="percent">{{ build.passed_case_runs_percent|floatformat:1 }}% ({{ build.passed_case_runs_count }})</div>
				</div>
			</td>
			<td width="100">Failed Case-Run</td>
			<td width="100">
				<div class="progress-bar">
					<div class="progress-inner" style="width:auto;	margin-right:-50px;text-align:center">
						<div class="progress-failed" style="width:{{ build.failed_case_runs_percent|floatformat:1 }}px;">&nbsp;</div>
					</div>
					<div class="percent">{{ build.failed_case_runs_percent|floatformat:1 }}% ({{ build.failed_case_runs_count }})</div>
				</div>
			</td>
			<td>&nbsp;</td>
		</tr>
		{% endfor %}
	</table>

	{% include "report/custom_details_status_matrix.html" %}
	<div class="failed_caserun">All Failed Case-Run List</div>
	{% include "report/custom_details_case_runs.html" with case_runs=failed_case_runs %}
	<div class="blocked_caserun">All Blocked Case-Run List</div>
	{% include "report/custom_details_case_runs.html" with case_runs=blocked_case_runs %}
	{% endif %} {# endif report_errors #}
</div>
{% endblock %}
